#ifndef DBUSMETHODMODEL_HPP
#define DBUSMETHODMODEL_HPP

#include <QAbstractItemModel>
#include <qdom.h>
#include <QtDBus>
#include "common.hpp"
struct DbusMethodItem;
class DbusMethodModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit DbusMethodModel(QObject *parent = nullptr);
    DbusMethodItem *getItem(const QModelIndex &index);

signals:
Q_SIGNALS:
    void busError(const QString &text);
public slots:

    // QAbstractItemModel interface
public:
    QModelIndex index(int row, int column, const QModelIndex &parent) const override;
    QModelIndex parent(const QModelIndex &child) const override;
    int rowCount(const QModelIndex &parent) const override;
    int columnCount(const QModelIndex &parent) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    void refresh(const QString &bname, const QString &bservice, const QString &bPath, const QString &bInterface);
    void refreshlocalMethod();
private:
    DbusMethodItem *root;
    QDomDocument introspect(const QString &bname, const QString &bservice, const QString &bPath, const QString &bInterface);

    QDBusConnection getBus(QString name);
    void addMethods(DbusMethodItem *parent, const QDomElement &iface);

    // QAbstractItemModel interface
public:
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    // QAbstractItemModel interface
public:
    QMimeData *mimeData(const QModelIndexList &indexes) const override;

    // QAbstractItemModel interface
public:
    Qt::DropActions supportedDragActions() const override;

    // QAbstractItemModel interface
public:
    QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
};



















#endif // DBUSMETHODMODEL_HPP
